package com.kjlink.internal.workreport.stats.vo;

import com.kjlink.internal.workreport.helper.ReportCommonHelper;
import com.kjlink.internal.workreport.stats.model.ProjectTimeStats;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * 描述:
 * 数据项
 *
 * @author Vic.xu
 * @since 2024-05-28 14:16
 */
public class SerieVo {

    private String name;

    private String type;


    /**
     * 数据列表 对应 xAxis 的数据大小
     */
    private List<Number> data;

    //为了显示0值 设置柱体最小高度
    private int barMinHeight = 2;

    public SerieVo() {
        this.data = new ArrayList<>();
    }

    public SerieVo(String name, String type) {
        this.name = name;
        this.type = type;
        this.data = new ArrayList<>();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public List<Number> getData() {
        return data;
    }

    public void setData(List<Number> data) {
        this.data = data;
    }

    public int getBarMinHeight() {
        return barMinHeight;
    }

    public void setBarMinHeight(int barMinHeight) {
        this.barMinHeight = barMinHeight;
    }

    public void addData(Number data) {
        if (data == null) {
            this.addData(BigDecimal.ZERO);
        } else {
            this.data.add(ReportCommonHelper.toPersonDaysNumber(data.intValue()));
        }
    }

    public void addData(ProjectTimeStats status) {
        if (status == null) {
            this.addData(BigDecimal.ZERO);
        } else {
            this.data.add(ReportCommonHelper.toPersonDaysNumber(status.getTotal()));
        }

    }
}
